import request from "@/request/baseAxios";

// 获取全部用户信息
export const getUsersList = () => {
  return request({
    url: "/api/users",
    method: "get",
  });
};

export const getUserById = (id) => {
  return request({
    url: `/api/users/${id}`,
    method: "get",
  });
};

export const updateUser = (id, data) => {
  return request({
    url: `/api/users/${id}`,
    method: "put",
    data,
  });
};

export const getUserInfo = () => {
  return request({
    url: `/api/users/user/info`,
    method: "get",
  });
};

export const userLogin = (username, password) => {
  return request({
    url: "/api/users/login",
    method: "post",
    data: { username, password },
  });
};

export const userLogout = (refreshToken) => {
  return request({
    url: "/api/users/logout",
    method: "post",
    data: {
      refreshToken,
    },
  });
};

export const postRefreshToken = (refreshToken) => {
  return request({
    url: "/api/users/refresh-token",
    method: "post",
    data: {
      refreshToken,
    },
  });
};

export const userDelete = (id) => {
  return request({
    url: `/api/users/${id}`,
    method: "delete",
  });
}

export const userRegister = (username,password) => {
  return request({
    url: "/api/users/register",
    method: "post",
    data:{username,password}
  });
}